﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BDS3M.Admin.Controls
{
    public partial class ListNote : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    //Them du lieu vao cat 1

                    rpt_note.DataSource = DAL.DCollector.DBCollector.Instance.StoredProcedureSelectByColumns("tbl_Note", " * ", "selectbycolumns");

                    rpt_note.DataBind();
                }
            }
            catch (Exception)
            {
                Response.Redirect("/error.htm");
            }          
        }

        protected void rpt_note_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "delete")
                {
                    int id = Convert.ToInt32(e.CommandArgument.ToString());

                    DAL.DCollector.DBCollector.Instance.CallStored("callstored", "delete from tbl_Note where Note_ID=" + id, false);

                    rpt_note.DataSource = DAL.DCollector.DBCollector.Instance.StoredProcedureSelectByColumns("tbl_Note", " * ", "selectbycolumns");

                    rpt_note.DataBind();
                }
            }
            catch (Exception)
            {
                Response.Redirect("/error.htm");
            }
           
        }
    }
}